package com.fy.service.server.controller;

import com.alibaba.fastjson.JSONObject;
import com.fy.common.model.ResponseResult;
import com.fy.service.service.MessageService;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.integration.core.MessageProducer;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;


/**
 * Description： 测试作用
 */
@ApiIgnore
@Controller
@RequestMapping(value = "/mq")
public class RocketMqController {

    @Autowired
    private RocketMQTemplate rocketMQTemplate;


    @ResponseBody
    @RequestMapping(value = "/send", produces = {"application/json;charset=UTF-8"})
    public ResponseResult TestSend(@RequestParam(value = "topic") String topic) {


        try {

            rocketMQTemplate.convertAndSend(topic, JSONObject.toJSONString("测试消息路由转发").getBytes());


        } catch (Exception e) {
            e.printStackTrace();
            //throw new BusinessException(ErrorType.DELETE_CHAT_TYPE_INVALID);
        }
        return ResponseResult.ok();
    }

}